/**
 * 
 */
package neptune.web.client.view.components.dialogs;

import neptune.web.client.services.ApplicationDataProvider;
import neptune.web.client.view.input.DefaultInputValidator;
import neptune.web.client.view.input.EmailValidator;

import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.TextBox;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * 
 */
public class UserDetailsDialog extends PropertiesDialog {

	public static String USERNAME = "Username";
	public static String PASSWORD = "Password";
	public static String ROLE = "Role";
	public static String EMAIL = "e-Mail";
	private TextBox usernameTB;

	public UserDetailsDialog() {
		super(null);
		this.setText("User Details Window");
		usernameTB = new TextBox();
		usernameTB.setEnabled(false);
		this.addProperty(USERNAME, usernameTB, new DefaultInputValidator());
		this.addProperty(PASSWORD, new TextBox(), new DefaultInputValidator());

		final ListBox list = new ListBox();

		// Recupera le informazioni sui ruoli degli utenti definiti
		String[] roles = ApplicationDataProvider.getInstance().getUserRoles();
		for (int i = 0; i < roles.length; i++) {
			list.addItem(roles[i]);
		}

		this.addProperty(ROLE, list);

		this.addProperty(EMAIL, new TextBox(), new EmailValidator());
	}
	
	/**
	 * Default is false
	 * 
	 * @param editable
	 */
	public void setUsernameEditable(boolean editable){
		usernameTB.setEnabled(editable);
	}
}
